from django.db import models

# Create your models here.
#部门表
class Dept(models.Model):
    name = models.CharField(max_length=30)
    t_number = models.IntegerField()

    def __str__(self):
        return self.name

    class Meta:
        db_table='dept'

#部门表
class Emp(models.Model):
    name = models.CharField(max_length=30)
    dept = models.ForeignKey('dept',on_delete=models.CASCADE)

    def __str__(self):
        return self.name

    class Meta:
        db_table='emp'
#角色表
class Roles(models.Model):
    name = models.CharField(max_length=30)

    def __str__(self):
        return self.name
    class Meta:
        db_table='roles'

#后台用户表
class Admin_User(models.Model):
    username = models.CharField(max_length=30)
    password_hash = models.CharField(max_length=255)
    is_admin = models.IntegerField
    roles_id = models.ForeignKey('roles',on_delete=models.CASCADE)

    def __str__(self):
        return self.username
    class Meta:
        db_table='admin_user'

#资源表
class Resource(models.Model):
    name = models.CharField(max_length=30)
    url = models.CharField(max_length=100)
    roles = models.ManyToManyField('roles',related_name='roles')

    def __str__(self):
        return self.name
    class Meta:
        db_table='resource'


